home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume26 / wroff / part01 next >
Encoding:
Text File  |  1991-12-11  |  53.6 KB  |  2,004 lines

  1. Newsgroups: comp.sources.misc
  2. From: bkw@uecok.ECOK.EDU (Bill Walker)
  3. Subject:  v26i097:  wroff - text formatter for HP LaserJet with PDS 25-font cartridge, Part01/05
  4. Message-ID: <csm-v26i097=wroff.003501@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 14fa3c967fe26482c2cb27ec89b8edfc
  6. Date: Tue, 10 Dec 1991 06:35:29 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: bkw@uecok.ECOK.EDU (Bill Walker)
  10. Posting-number: Volume 26, Issue 97
  11. Archive-name: wroff/part01
  12. Environment: SCO, HPUX, MS-DOS, CPM-68K
  13.  
  14. Here is a text formatter in the spirit of nroff, but attuned to 
  15. HP Laserjet II printers with the Pacific Data Systems 25-in-One
  16. font cartridge installed.  
  17.  
  18. The original was posted to comp.sources.unix several years ago, and
  19. the archive copy on uunet has been messed up ever since.  This
  20. new posting is much improved, and seems to have all of its parts present.
  21. Hope someone enjoys it.
  22.  
  23. bw@cs.ecok.edu
  24.  
  25. ------------------------------- cut here ------------------
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then feed it
  28. # into a shell via "sh file" or similar.  To overwrite existing files,
  29. # type "sh file -c".
  30. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  31. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  32. # Contents:  README Fonts Fonts/PB14L MACROS TestData bin doc
  33. #   doc/wroff.1.w doc/wroff.tut.w source source/format.c
  34. # Wrapped by kent@sparky on Tue Dec 10 00:26:38 1991
  35. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  36. echo If this archive is complete, you will see the following message:
  37. echo '          "shar: End of archive 1 (of 5)."'
  38. if test -f 'README' -a "${1}" != "-c" ; then 
  39.   echo shar: Will not clobber existing file \"'README'\"
  40. else
  41.   echo shar: Extracting \"'README'\" \(4198 characters\)
  42.   sed "s/^X//" >'README' <<'END_OF_FILE'
  43. XThis contains the newest (August, 1991) version of wroff.
  44. X
  45. XWroff is a text formatter, similar to, but not compatible with,
  46. Xnroff and troff.  It has much the same command structure, but
  47. Xit is optimized for use with the Hewlett-Packard LaserJet II
  48. Xprinter and the Pacific Data Systems 25-in-One Font Cartridge.
  49. X
  50. XWroff is written in "C" and has been "ported" to
  51. X    Altos 5000 (SCO UNIX on 80486)
  52. X    Altos 2000 (80386) (UNIX)
  53. X    Altos 3068 (68020)  (UNIX)
  54. X    Altos 586/986 (Xenix on 8086)
  55. X    HP-UX running who knows what on what
  56. X    CPM-68K  (honest!)
  57. X    MSDOS with Turbo C++
  58. X
  59. X
  60. XIt does kerning, and a few other nice things.  It is rather fast,
  61. Xand has had a LOT of text put through it in the past couple of years.
  62. X
  63. X
  64. XHere is a list of directories and files:
  65. X
  66. XFonts/         -- width tables for fonts
  67. XMACROS/        -- some demonstration macros and test files
  68. XMANIFEST     -- list of contents for the shar archive
  69. XMakefile     -- a makefile for the whole thing
  70. XREADME         -- this file
  71. XTestData/    -- some interesting test data
  72. Xdoc/        -- documentation
  73. Xsource/        -- source code for wroff
  74. X*.bat        -- batch files for testing under MSDOS
  75. X
  76. X
  77. XTo create wroff under UNIX, just type "make" in this directory.  This will 
  78. Xcreate a non-stripped executable called "a.out", which is suitable for testing.
  79. X
  80. XIf you are using HP-UX, you will need to use the HPUX.make file instead.
  81. X
  82. XIf you are using MSDOS, you must "cd source" and use the file "make.tcc"
  83. Xinstead of the UNIX make. In this case, you must perform the testing
  84. Xusing the "*.bat" files.  Wroff has been tested under Turbo C++, but
  85. Xunder no other MSDOS compiler.  The binaries are available from bw@cs.ecok.edu.
  86. X
  87. XThe "a.out" version expects to find the font files in a directory
  88. Xcalled "./Fonts", so it will only run in this directory.
  89. X
  90. XYou can test this version by typing
  91. X    make install
  92. X    make test
  93. X    make sampler
  94. XYour printer (and serial line!) must be able to handle 8-bit data.
  95. XThis "make install" will not do anything drastic to your file system,
  96. Xand it can be run without being super user.
  97. X
  98. XYou should get about three pages of printing that illustrate
  99. Xmost (but not all) of the fonts available to the Pacific Data
  100. XSystems Cartridge.  
  101. X
  102. XOnce you are convinced that everything is in good order, you should
  103. Xedit the Makefile to indicate a full path name for the Fonts directory,
  104. Xand the BINDIR, and then recompile everything.  You will probably have to
  105. Xsay something like:
  106. X    rm source/*.o
  107. X    make
  108. X
  109. Xto recompile, and then
  110. X    make install
  111. Xas superuser to install the fonts and the real live wroff.
  112. XThis will create some files at various places in your filesystem, so
  113. Xif you are nervous, be sure to examine the Makefile carefully.
  114. XIt shouldn't have anything in it to bother anyone.
  115. X
  116. XAfter installation,
  117. X    make test
  118. Xor
  119. X    make sampler
  120. X
  121. Xis useful to increase your confidence in wroff.
  122. X
  123. XHave fun!
  124. X
  125. X
  126. X
  127. X
  128. X*************************************************
  129. XAugust, 1991:
  130. X
  131. XAt the suggestion of Marc Veeneman (marc@marcal.uucp),
  132. Xwroff is now more "mailable".  All ESC characters in the font
  133. Xfiles have been replaced with a much more mailable "E" character, which
  134. Xwroff replaces with a real ESC when it reads the font files.
  135. X
  136. XWroff may not accept files with super-long lines, such as those
  137. Xwhich are produced by some commercial packages.  Mr. Veeneman
  138. Xalso suggests that in these cases, you can change MAXSTR in defs.h
  139. Xto something ridiculous, and defeat the miscreants.
  140. X(You may also have to make MAXBUF in the same file even more
  141. Xridiculous.) 
  142. X
  143. X
  144. X**************************************************************
  145. XSeptember 4, 1991
  146. X
  147. XStudent Connie Nabors (cnabors@student.ecok.edu)
  148. Xmodified the original wroff to allow it to be compiled
  149. Xunder Turbo C++ on MSDOS.
  150. X
  151. XAlso, the ".tm" (transparent mode) command has been modified
  152. Xto allow the new "wtbl" program to feed wroff directly.
  153. X
  154. X**************************************************************
  155. X
  156. XAlso, note that the distribution of wroff that is archived on
  157. Xuunet does not contain all of the appropriate files.  New
  158. Xfiles may be requested by sending mail to
  159. X
  160. X    bw@cs.ecok.edu
  161. X
  162. X
  163. X
  164. X    Surface mail, e-mail,  or telephone questions are welcome:
  165. X
  166. X    Bill Walker
  167. X      (bw@cs.ecok.edu)
  168. X    Department of Computer Science
  169. X    East Central University
  170. X    Ada, Oklahoma  74820
  171. X    405 332 8000 x 594
  172. X
  173. END_OF_FILE
  174.   if test 4198 -ne `wc -c <'README'`; then
  175.     echo shar: \"'README'\" unpacked with wrong size!
  176.   fi
  177.   # end of 'README'
  178. fi
  179. if test ! -d 'Fonts' ; then
  180.     echo shar: Creating directory \"'Fonts'\"
  181.     mkdir 'Fonts'
  182. fi
  183. if test -f 'Fonts/PB14L' -a "${1}" != "-c" ; then 
  184.   echo shar: Will not clobber existing file \"'Fonts/PB14L'\"
  185. else
  186.   echo shar: Extracting \"'Fonts/PB14L'\" \(313 characters\)
  187.   sed "s/^X//" >'Fonts/PB14L' <<'END_OF_FILE'
  188. XE&l0OE(1UE(sp10h13.9vs1b11T
  189. X30
  190. X30
  191. X30
  192. X30
  193. X30
  194. X30
  195. X30
  196. X30
  197. X30
  198. X30
  199. X30
  200. X30
  201. X30
  202. X30
  203. X30
  204. X30
  205. X30
  206. X30
  207. X30
  208. X30
  209. X30
  210. X30
  211. X30
  212. X30
  213. X30
  214. X30
  215. X30
  216. X30
  217. X30
  218. X30
  219. X30
  220. X30
  221. X30
  222. X30
  223. X30
  224. X30
  225. X30
  226. X30
  227. X30
  228. X30
  229. X30
  230. X30
  231. X30
  232. X30
  233. X30
  234. X30
  235. X30
  236. X30
  237. X30
  238. X30
  239. X30
  240. X30
  241. X30
  242. X30
  243. X30
  244. X30
  245. X30
  246. X30
  247. X30
  248. X30
  249. X30
  250. X30
  251. X30
  252. X30
  253. X30
  254. X30
  255. X30
  256. X30
  257. X30
  258. X30
  259. X30
  260. X30
  261. X30
  262. X30
  263. X30
  264. X30
  265. X30
  266. X30
  267. X30
  268. X30
  269. X30
  270. X30
  271. X30
  272. X30
  273. X30
  274. X30
  275. X30
  276. X30
  277. X30
  278. X30
  279. X30
  280. X30
  281. X30
  282. X30
  283. X30
  284. END_OF_FILE
  285.   if test 313 -ne `wc -c <'Fonts/PB14L'`; then
  286.     echo shar: \"'Fonts/PB14L'\" unpacked with wrong size!
  287.   fi
  288.   # end of 'Fonts/PB14L'
  289. fi
  290. if test ! -d 'MACROS' ; then
  291.     echo shar: Creating directory \"'MACROS'\"
  292.     mkdir 'MACROS'
  293. fi
  294. if test ! -d 'TestData' ; then
  295.     echo shar: Creating directory \"'TestData'\"
  296.     mkdir 'TestData'
  297. fi
  298. if test ! -d 'bin' ; then
  299.     echo shar: Creating directory \"'bin'\"
  300.     mkdir 'bin'
  301. fi
  302. if test ! -d 'doc' ; then
  303.     echo shar: Creating directory \"'doc'\"
  304.     mkdir 'doc'
  305. fi
  306. if test -f 'doc/wroff.1.w' -a "${1}" != "-c" ; then 
  307.   echo shar: Will not clobber existing file \"'doc/wroff.1.w'\"
  308. else
  309.   echo shar: Extracting \"'doc/wroff.1.w'\" \(15433 characters\)
  310.   sed "s/^X//" >'doc/wroff.1.w' <<'END_OF_FILE'
  311. X.fo \f0Bill Walker/page #/October 27, 1989\fP
  312. X.NAME wroff
  313. X.SYNOPSIS
  314. Xwroff [-sdpk] [-b n] [-e n] [-o outfile] [-t #] filelist
  315. X
  316. X.FUNCTION
  317. Xwroff is a general text formatting program.  Options:
  318. X.sp
  319. X.nf
  320. X.in +5
  321. XSwitch              Action
  322. X.in +2
  323. X
  324. X-p        Do not effect font changes (default is p)
  325. X-b        begin printing with page n (default 1)
  326. X-e        end printing with page n (default 32767)
  327. X-o        place output on outfile
  328. X-k        do not use formfeeds to advance to new page
  329. X-s              scan text for errors only - do not print
  330. X-t #        expand tabstops (default 8 spaces)
  331. X            (use -t 0 to retain tab characters)
  332. X-v        print version number -- no text processing
  333. X
  334. X.in -7
  335. X.fi
  336. X.PP
  337. XSwitch "-p" causes special characters such as
  338. Xthose that produce italics or boldface not to be output.
  339. XAn unrecognized command will cause wroff to terminate.  
  340. X.PP
  341. XWhen writing to standard output, wroff does not emit special
  342. Xcharacters.  This allows work to be previewed on the screen
  343. Xbefore it is printed.  However, the screen only approximates
  344. Xthe true output.
  345. X.PP
  346. XThe wroff commands are discussed in the following pages.
  347. X.BUGS
  348. XThe "preview" mechanism should provide more realistic output.
  349. X.bp
  350. X.in 5
  351. X.nf
  352. X.ce 2
  353. X.bd 2
  354. X.it 1
  355. XWroff
  356. XCommands
  357. X.sp 2
  358. X\fT
  359. XCommand           default           Effect
  360. X
  361. X.cc !
  362. X!in +2
  363. X.bd n              1             boldface next n lines
  364. X.bp n            next            advance to next page
  365. X.br              none            break
  366. X.cc c             .              change command char to c
  367. X.ce n             1              center next n lines
  368. X.dc c             /              change delimiter to c in titles 
  369. X.de name         none            start macro definition
  370. X.di XX        none         start diversion to XX
  371. X.ed         none         end diversion
  372. X.en              none            end macro definition
  373. X.et         none         end transparent mode
  374. X.fi              true            set fill on
  375. X.fm  fontname    P18bl         mount font on post M
  376. X.fo string    "/page #/"     define footer
  377. X.gx x          0         move horizontally x dots 
  378. X.gy y          0         move vertically y dots
  379. X.he string     none         define header
  380. X.hr n           0         horizontal rule, length n
  381. X.if (expr) XX               if (expr) is true, call macro XX
  382. X.in n             10             set left margin to n  
  383. X.it n              1             italicize next n lines
  384. X.ju              true            justify right margin
  385. X.lp str             none         label indented paragraph
  386. X.ls n              1             set line spacing to n
  387. X.m3 n          24         margin (dots) before footer
  388. X.ne n              1             need n lines
  389. X.nf n            false,n=2       set fill off, theshold to n
  390. X.nj              false           do not justify right margin
  391. X.pc c              #             set page char to c
  392. X.pl n             480            set page length to n dots
  393. X                    (48 per vertical inch )
  394. X.pm n          10             place paragraph labels left
  395. X                  by this much (characters)
  396. X.rj n         current         process left jagged, right justified
  397. X                right margin     use .rj 0 to turn off
  398. X.rm n             70             set right margin to n
  399. X.rt         none         reset traps
  400. X.so name         none            source a file
  401. X.sp n              1             space down n lines
  402. X.ti n              0             temporary indent by n
  403. X.tf string    "l c r"         title format
  404. X.tl XX string     none           set variable XX to string
  405. X.tm          none         enter transparent mode
  406. X.vr n           0         vertical rule, length n
  407. X.vs n           12             vertical spacing between lines
  408. X                    (dots)
  409. X.ul n              1             underline next n lines
  410. X.wh n  XX     none         set trap XX at vertical position n
  411. X..         none         comment line
  412. X\\fc              none            embedded font change
  413. X                   (c = B, I, M, T, U, P, 0, 1, 2)
  414. X\\{XX}          none          interpolate macro XX
  415. X\\(reg)          none        interpolate register reg as an integer
  416. X\\(regC)        none            interpolate register reg as a character
  417. X\\[expr]    none        evaluate register expression
  418. X\\f|        none        provide "anchor" in nonfill mode
  419. X
  420. X!cc .
  421. X.bp
  422. X\fP
  423. X.ce
  424. X\fIVariables\fP
  425. X.nf
  426. X
  427. XAll measurements in "dots"
  428. X.sp 2
  429. X     registers and default values
  430. X
  431. X    # =  1         \f| start at page 1 
  432. X    A =  2         \f| the next page 
  433. X    B = 24         \f| bottom margin of 24 dots 
  434. X    C = 0        \f| center this many lines 
  435. X    D = 0         \f| vertical length of last diversion 
  436. X    E = 0          \f| italicize next n lines 
  437. X    F = 0         \f| current font 
  438. X    G = 0         \f| boldface next n lines 
  439. X    H = TRUE      \f| justify lines 
  440. X    I = TRUE       \f| start in FILLMODE = TRUE 
  441. X    J = '/'     \f| a SLASH mark 
  442. X    L = 300     \f| left margin of 300 dots  - 1 inch 
  443. X    M = 0        \f| temporary indent 
  444. X    O = '#'       \f| page character 
  445. X    P = 480     \f| page length 
  446. X    Q = 0         \f| number of printable characters in outbuf 
  447. X    R = 2100    \f| right margin of 2100 dots - 7 inches 
  448. X    S = 1         \f| line spacing 
  449. X    T = 0         \f| top margin of 0 dots 
  450. X    U = 30        \f| width of a space character in dots 
  451. X    V = 10         \f| current vertical spacing 
  452. X    W = 10         \f| indented paragraph start  in characters 
  453. X    X = 0         \f| current horizontal position 
  454. X    Y = REG('T')    \f| current vertical position 
  455. X    Z = FALSE     \f| underline state 
  456. X    ! = 8         \f| tabstops every 8 characters 
  457. X    _ = 24         \f| margin before footer 
  458. X.bp
  459. X.fi
  460. X.ce 10
  461. X\fIWroff Commands\fP
  462. X.ce 0
  463. X.sp 2
  464. X.de CMD
  465. X.in 20
  466. X.sp
  467. X.lp $1 $2
  468. X.en
  469. X
  470. X.CMD bd
  471. X"bd n" is used to boldface the next n lines.  If n is not specified,
  472. Xthe
  473. Xdefault is to boldface the next line.
  474. XSince \fBwroff\fP supports in-line font changes, this command is
  475. Xnot really very useful.
  476. X.CMD bp
  477. X"bp n" is used to advance to the next page and number it "n".  If 
  478. X"n" is not specified, the default is to number pages
  479. Xsequentially.
  480. X.CMD br
  481. XThe "br" command will always cause any collected output to
  482. Xbe printed.
  483. X.CMD cc
  484. XThe "command character" is the character that preceeds an embedded command.
  485. XThe character defaults to a ".", but can be changed to any
  486. Xcharacter by issuing "cc c", where c is any character.
  487. X.CMD ce
  488. X"ce n" centers the next n lines.  If n is not specified, the
  489. Xdefault is to center the next line.
  490. X.CMD dc
  491. XIn titles, such as the footers and headers, the fields are
  492. Xdelineated by using a "delimiter character".  For instance,
  493. Xthe default footer is "/page #/".  The "/" delimits the
  494. Xfields.  This delimiter (default "/") can be changed by
  495. Xusing the "dc c" command.
  496. X.CMD de
  497. XThis command starts a macro definition.  Use "de name" to
  498. Xbegin the definition of a macro named "name".  There is no
  499. Xdefault name.  A macro definition will continue until the
  500. X"en" command is recognized. 
  501. X.CMD di
  502. XStart a diversion named "name" by issuing "di name".  Text
  503. Xis copied into the diversion until the "ed" command is
  504. Xfound.
  505. X.CMD ed
  506. XEnd a diversion.  
  507. X.CMD en
  508. XEnd a macro.  Caution:  if you define a macro, be sure to
  509. Xend it!
  510. X.CMD et
  511. XEnd transparent print.  Any lines between "tm" and "et" will
  512. Xbe copied to the output without any processing (other than
  513. Xfor margins ).
  514. X.CMD fi
  515. X"fi" tells \fBwroff\fP to begin to fill lines.  That means
  516. Xthat both the left and the right margins will appear
  517. Xstraight.
  518. X.CMD fm
  519. XThe "fm name" command mounts a font with the given name on
  520. Xfont post "M".  To access that font, use \\fM to start, and
  521. X\\fP to return to the previous font.
  522. XThere is a list of available fonts at the end of this
  523. Xdocument.
  524. X.CMD fo
  525. X"fo string" defines the page footer to be "string".  The
  526. Xstring is constructed by examining the title format string,
  527. Xwhich is defined by "tf", and replacing any page character
  528. Xby the current page number.  (See "pc" to change the page
  529. Xcharacter.)
  530. XThe placement of the footer on the page can be controled by
  531. Xusing "m3". 
  532. X.CMD gx
  533. X"gx x" is the "go to x" command.  "x" is measured in "dots"
  534. Xfrom the left printable margin.  There are 300 "dots" to an
  535. Xinch.  "gx" is used to move horizontally across a page.
  536. X.CMD gy
  537. X"gy y" is the "go to y" command.  "y" is measured in "dots"
  538. Xfrom the top printable margin.   There are 48 "dots" to an
  539. Xinch.  "gy" is used to move vertically in a page.
  540. X.CMD he
  541. X"he string" sets the page header, in the same way that "fo"
  542. Xsets the footer.
  543. X.CMD hr
  544. X"hr n" draws a horizontal rule (a line) from the current x position
  545. Xto the right.  This line is of length n (default 0) in dots.
  546. X.CMD if
  547. X"if (expr) macname" will evaluate the expression and execute the
  548. Xmacro names "macname" if the expression is true. 
  549. XIf the expression is an arithmetic expression, the evaluator
  550. Xregards "0" as "TRUE".
  551. X.CMD in
  552. XThe "in n" command controls the left margin.  The default for n is 10.
  553. XIn contrast to other commands, n is measured in deci-inches.  The default
  554. Xleft margin is therefore 1 inch from the left printable margin.
  555. X.CMD it
  556. X"it n" will italicize the next n lines.  The default is to italicize 
  557. Xone line.  Since \fBwroff\fP supports in-line font changes, this command
  558. Xis not really useful.
  559. X.CMD ju
  560. XIssuing "ju" will cause right margin justification to take place.  To
  561. Xgain a "ragged right" margin, turn justification off with "nj".
  562. X.CMD lp
  563. XUse "lp str" to label a paragraph with the string "str".  This label is
  564. Xplaced to the left of the paragraph a distance of 10 deci-inches.  This
  565. Xdistance can be changed with the "pm" command.
  566. X.CMD ls
  567. XUse "ls n" to set the line spacing to n.  (The default is 1).  For instance,
  568. Xto double space output, use "ls 2".
  569. X.CMD m3
  570. XBefore placing a footer, wroff provides a small margin.  The default is to provide
  571. Xone-half inch (24 dots), and then place the footer.  This can be changed
  572. Xby using "m3 n", where n is measured in dots. (48 dots per vertical inch.)
  573. X.CMD ne
  574. X"ne n" means that \fBwroff\fP should guarantee that there 
  575. Xis at least n lines left on the current page (default n=1).  If this much
  576. Xspace does not remain on the current page, \fBwroff\fP will turn up a new
  577. Xpage before proceeding.
  578. X.CMD nf
  579. XThe "nf" command causes \fBwroff\fP to process in non-fill
  580. Xmode.  In fill mode, as many words as possible are packed on
  581. Xa line before the line is printed.  If "justify" mode (see
  582. X"ju" and "nj") is also on, the right margin is also
  583. Xjustified.  The "nf" command turns fill mode off, and in
  584. Xeffect causes lines to appear as they are typed.  This is
  585. Xespecially useful for tables.  The "anchor" character (see
  586. Xbelow) will be helpful in making tables line up properly.
  587. X.CMD nj
  588. XEnter "non-justify" mode.  
  589. XIn non-justify mode, the right margin is not justified.
  590. XNon-justify mode can coexist with fill mode to pack as many
  591. Xwords as possible on a line, without squaring up the right
  592. Xmargin.  The default mode is "justify".
  593. X.CMD pc
  594. XIn headers or footers, the (default) symbol "#" is used to represent
  595. Xsomething that should be replaced with the current page
  596. Xnumber.  The symbol "#" can be changed to any character c by
  597. Xusing "pc c".
  598. X.CMD pl
  599. X"pl n" is used to set the length of a page to n dots.
  600. X(default is n=480, or 10 inches)  This command is little
  601. Xused, unless you use odd sized paper in your laser printer.
  602. X.CMD pm
  603. XSee the "lp" command above.  The "pm n" command (default
  604. Xn=10) sets the margin for a paragraph label.  The parameter
  605. Xn is measured in deci-inches.
  606. X.CMD rj
  607. XUse the "rj" command to cause text to be justified on the
  608. Xright, with a ragged left margin.  This is useful for
  609. X"glitzy" work.
  610. X.CMD rm
  611. XThe "rm n" command sets the right margin.  "n" is measured
  612. Xin deci-inches, with a default of 70 (7 inches).
  613. X.CMD rt
  614. XWhen "traps" (see "wh") are placed on a page, the
  615. Xtraps are "sprung" as the location at which they are placed
  616. Xis passed.  A "sprung" trap will not be sprung a second time
  617. Xon the same page.  If you want to "reset" a trap for some
  618. Xreason (perhaps you used "gy" to move above it), use "rt"
  619. Xto reset \fIall\fP the traps on a page.  It is not possible
  620. Xto selectively reset traps.
  621. X.CMD so
  622. XSource an external file.  "so filename" will attempt to
  623. Xlocate file "filename" and include it as though it were part
  624. Xof the current file.  Nested "so" commands are legal.  i.e.
  625. Xa file that is 'sourced' may in turn 'source' another file.
  626. X.CMD sp
  627. XSpace down n lines by using "sp n".  The default for n is
  628. X1.
  629. X.CMD ti
  630. XUse "ti n" (default n=0) to indent \fIonly the next line\fP
  631. Xby n deci-inches.  (Think "temporary indent")
  632. X.CMD tf
  633. XA "title format" is a string that tells the tl command
  634. X(below) how to interpret a given string.
  635. XThe current title format is used to interpolate strings
  636. Xusing the "tl" command.
  637. XThe default title format is "l c r", meaning to interpret
  638. Xthe string as having three fields, delimited by "/" (see
  639. X"dc").  The first field will be left-justified, the second
  640. Xfield will be centered, and the third
  641. Xfield
  642. Xwill be 
  643. Xright justified, all within printed fields computed from the
  644. Xnumber of fields specified in the title format.  
  645. XTo place the second field at the right of the center printed
  646. Xfield, use "tf l r r".
  647. X.CMD tl
  648. X"tl string" is used to interpolate the string into the output, where the
  649. Xstring is formatted according to the current 'title format'.  (See "tf".)
  650. X.CMD tm
  651. XEnter transparent print mode.  No further processing is done
  652. Xon text, but the text is copied directly from input to
  653. Xoutput until command "et" is encountered.  No font changes
  654. Xare executed, and \fBwroff\fP is likely to lose track of
  655. Xcurrent positions on the page.  Use "tm" only \fIin
  656. Xextremis\fP.
  657. X.CMD vr
  658. XDraw a vertical line n dots (48 per inch) long starting at the current
  659. Xposition.  Note that the positive direction is "down" the
  660. Xpage.
  661. X.CMD vs
  662. XAdjust the vertical spacing between lines of print.  This is
  663. Xoften useful to help "squeeze" a document onto a single
  664. Xpage.  "vs -1" will squeeze lines closer together by 1
  665. Xvertical dot.  The default is to space by 12 dots.
  666. X.CMD ul
  667. XUse "ul n" to underline the next n lines.  (default n = 1)
  668. X.CMD wh
  669. XSet a trap.
  670. XThe "wh" command has an unusual syntax.  The command "wh n
  671. XNAME" will execute macro "NAME" when the current vertical position
  672. Xon the page passes position n.  The syntax "wh -24 NP" would
  673. Xfire macro NP when the current vertical position was within
  674. X24 dots of the bottom of the page.  The macro must be
  675. Xdefined elsewhere.  Beware of firing undefined macros.  A
  676. Xmacro must be defined before the trap is fired, but need not
  677. Xbe defined before the trap is set.  It is legal to change a
  678. Xmacro definition without resetting a trap.
  679. X.CMD .
  680. XThe ".." command is a comment marker.  Actually,
  681. Xthe command should really be "CMDCHAR .", where the CMDCHAR
  682. Xis set by the "cc" command.  The rest of a line after ".."
  683. Xis taken as a comment.
  684. X.in 10
  685. X.bp
  686. X.ce 
  687. X\fBIn-Line Actions\fP
  688. X.sp 3
  689. X.PP
  690. X\fBwroff\fP has the ability to deal with various fonts.  It can also 
  691. Xinterpolate the value of a variable into the output stream, or call a
  692. Xmacro from anywhere within a line.  
  693. XAll of this is accomplished with "In-Line Actions".  
  694. X.PP
  695. XIn-Line Actions
  696. Xcan be placed anywhere within a line of text.
  697. X(This is opposed to \fIembedded commands\fP, which were
  698. Xdiscussed above, and which must appear on a line by
  699. Xthemselves.)  The "backslash" symbol (\\) is used to signal
  700. X\fBwroff\fP that an in-line action is present.
  701. X.PP
  702. XThe possible in-line actions are listed below:
  703. X.nf
  704. X.sp 2
  705. Xcommand        \f|Action
  706. X.in +2
  707. X\\fc        \f|in-line font change
  708. X        \f|  where c = B, I, M, T, U, P, 0, 1, 2, other
  709. X        \f|  B -    \f|boldface
  710. X        \f|  I -    \f|italicize
  711. X        \f|  M -    \f|mountable
  712. X        \f|  T -    \f|Courier (fixed)
  713. X        \f|  U -    \f|toggle underline
  714. X        \f|  P -    \f|return to previous
  715. X        \f|  0 -    \f|default font (Times Roman)
  716. X        \f|  1 -    \f|Presentation 18 point
  717. X        \f|  2 -    \f|Helvetica 6 point
  718. X        \f| other -    \f|interpolate "other" char
  719. X
  720. X\\{XX}        \f|interpolate macro named XX
  721. X\\(reg)        \f|interpolate the value of register reg
  722. X        \f|  as an integer
  723. X\\(regC)    \f|interpolate the value of register reg
  724. X        \f|  as a character
  725. X\\[expr]    \f|evaluate register expression -
  726. X        \f|  do not interpolate, see \\(reg) above
  727. X\\f|        \f|place "anchor" in text
  728. X.sp 2
  729. X.in -2
  730. X.fi
  731. END_OF_FILE
  732.   if test 15433 -ne `wc -c <'doc/wroff.1.w'`; then
  733.     echo shar: \"'doc/wroff.1.w'\" unpacked with wrong size!
  734.   fi
  735.   # end of 'doc/wroff.1.w'
  736. fi
  737. if test -f 'doc/wroff.tut.w' -a "${1}" != "-c" ; then 
  738.   echo shar: Will not clobber existing file \"'doc/wroff.tut.w'\"
  739. else
  740.   echo shar: Extracting \"'doc/wroff.tut.w'\" \(16027 characters\)
  741.   sed "s/^X//" >'doc/wroff.tut.w' <<'END_OF_FILE'
  742. X.fo \f0Bill Walker/page #/October 18, 1989\fP
  743. X.ce 10
  744. X\fBWroff Tutorial\fP
  745. X.ce 0
  746. X.sp 3
  747. X.in +5
  748. X.de PP
  749. X.sp
  750. X.ti +5
  751. X.en
  752. X.de OP
  753. X.sp
  754. X.ti -5
  755. X.en
  756. X.OP
  757. X\fBIntroduction:\fP  
  758. X.ls 2
  759. X.PP
  760. X"Wroff" is a general purpose text formatter,
  761. Xwritten in the spirit of Unix's \f2trademark of AT&T\fP 
  762. X\f1*roff\fP family.  The purpose
  763. Xof this document is to make the reader able to use "wroff"
  764. Xfor preparing documents.
  765. X.PP
  766. XWroff has been specifically "tuned" to the Hewlett-Packard
  767. XLaserJet II printer.  Most of the system defaults will
  768. Xprovide some reasonable output no matter \fBwhat\fP input is
  769. Xpresented.  The LaserJet can do \fBboldface\fP, \fUunderlining\fU,
  770. Xor even a \fB\fUcombination\fU\fP of the two.  Wroff 
  771. Xsupports \fIitalics\fP as well.  Wroff is aware that a page has
  772. X60 lines, and that a page should be printed with a left
  773. Xmargin of 1 inch.  (These can both be changed, of course.)
  774. X.PP
  775. XWroff, when processing text, will space twice after periods,
  776. Xquestion marks, exclamation marks, and colons.
  777. X.PP
  778. XThis document was prepared using\f1 wroff\fP.
  779. X.ls 1
  780. X.bp 
  781. X.OP
  782. X\fBEmbedded Commands:\fP  
  783. X.PP
  784. XWroff works by reading a text file,
  785. X(created by using "vi" under Unix) and rearranging the
  786. Xcontents of the file according to instructions which you
  787. Xgive by "embedding" certain commands in the file.
  788. X.PP
  789. XAn example of an embedded command would be this:
  790. X.cc #
  791. X
  792. X#nf
  793. X#in +5
  794. X.ce 3
  795. XThese three lines should
  796. Xbe centered on
  797. Xthe page.
  798. X
  799. X#cc .
  800. X
  801. X.in -5
  802. X.fi
  803. X
  804. XThe resulting output of wroff would be:
  805. X
  806. X.ce 3
  807. XThese three lines should
  808. Xbe centered on
  809. Xthe page.
  810. X
  811. X.PP
  812. XThe three lines are centered as a result of the ".ce 3"
  813. Xcommand being embedded in the text.  ".ce 3" means "center
  814. Xthe next three lines."  
  815. X.PP
  816. XThis is an example of an embedded command.  There are about
  817. Xforty such commands, most of which are not needed for
  818. Xordinary work.  An average document will require only two or
  819. Xthree of the commands.  The rest are present just to do
  820. X"fancy stuff".
  821. X.PP
  822. XAn embedded command is usually the only command on a line, and it
  823. Xusually starts with a period (".").  For this reason,
  824. Xembedded commands are often called "dot commands".  
  825. XIt is unusual to want to actually begin
  826. Xa line with a period, so this works OK.  If you have some reason for
  827. Xwanting to place a period at the first of a line (we did 
  828. Xabove in the example
  829. Xfor ".ce"), there is a way to do it.  
  830. X
  831. X.OP
  832. X\fBModes:\fP  
  833. X.PP
  834. XWe need to explain the difference in "fill mode",
  835. Xand "non-fill" mode.  
  836. X.PP
  837. XIn "fill mode", wroff will pack as many words as possible on
  838. Xa line, no matter how you typed the lines in the original
  839. Xfile.  If you are in "non-fill" mode, the lines will appear
  840. Xin the output just the way you typed them in.  Fill mode is
  841. Xusually "on", but you can turn it off with the command
  842. X".nf".  If you want it back on, just use ".fi".  Here is an
  843. Xexample:
  844. X
  845. X.cc #
  846. X#nf 
  847. X.nf
  848. XThese lines will appear 
  849. Xin non-fill mode, just the
  850. Xway they were typed in.
  851. XThis is useful for making tables and
  852. Xother things that need to line up
  853. Xin a certain way.
  854. X
  855. XHere is the output that results:
  856. X
  857. X
  858. X    These lines will appear
  859. X    in non-fill mode, just the
  860. X    way they were typed in.
  861. X    This is useful for making tables and
  862. X    other things that need to line up
  863. X    in a certain way.
  864. X
  865. X#fi
  866. XHere is the way things would look in fill
  867. Xmode.  Here is the raw text:
  868. X
  869. X#nf
  870. X.fi
  871. XThese lines will appear in
  872. Xfill mode, with the margins adjusted
  873. Xproperly.  This is the usual default for 
  874. Xtext, and so you can just omit the ".fi" if
  875. Xyou want to.
  876. X
  877. XHere is the way they appear after processing by wroff:
  878. X
  879. X#fi
  880. X#cc .
  881. XThese lines will appear in
  882. Xfill mode, with the margins adjusted
  883. Xproperly.  This is the usual default for 
  884. Xtext, and so you can just omit the ".fi" if
  885. Xyou want to.
  886. X
  887. X.OP
  888. X\fBjustify and non-justify modes:\fP  
  889. X.PP
  890. XSometimes we want to place
  891. Xas many words on a line as possible, but we do not want the
  892. Xright margins to be justified.  For instance, you may be
  893. Xwriting a business letter, and a ragged right margin gives
  894. Xsort of a "typed-by-hand" look to a paper.  Use the commands
  895. X".ju" and ".nj" to turn right margin justification on and
  896. Xoff.
  897. X.PP
  898. XHere is an example.  In the text file, we enter:
  899. X
  900. X.nf
  901. X.cc #
  902. X.fi
  903. X.nj
  904. XThese lines will appear with as
  905. Xmany words on a line as possible, but
  906. Xwith the right margin "ragged."
  907. XThis makes for a more "typed-by-hand" appearance,
  908. Xand is useful for correspondence.
  909. X
  910. XHere is the output:
  911. X
  912. X#nj
  913. X#fi
  914. XThese lines will appear with as
  915. Xmany words on a line as possible, but
  916. Xwith the right margin "ragged."
  917. XThis makes for a more "typed-by-hand" appearance,
  918. Xand is useful for correspondence.
  919. X#cc .
  920. X
  921. X.ju
  922. X.fi
  923. X.OP
  924. X\fBChanging the "command character":\fP  
  925. X.PP
  926. XSeveral times in the
  927. Xabove text, we had to print a period (a "dot") as the first
  928. Xcharacter on a line.  Since an embedded commands usually
  929. Xstarts with a "dot", we had to be sure that the
  930. Xdot at the first of a line could be ignored if we wanted it
  931. Xto be.  
  932. X.PP
  933. XThe "dot" is called the "command character", and actually
  934. Xany character can be used.  If we want some other character
  935. Xto become the command character instead, we could use the
  936. X".cc" command (for \fBc\fPhange \fBc\fPommand).  Here is how it
  937. Xworks.
  938. X.cc *
  939. X
  940. XAfter this, the command character is a "#".  For instance, 
  941. X
  942. X*nf
  943. X.cc #
  944. XI can now type a dot at the first of a line like this:
  945. X
  946. X.45 caliber automatic
  947. X
  948. X#cc .
  949. XNow the command character is changed back to a ".".
  950. X
  951. X*fi
  952. X*cc .
  953. X.PP
  954. XWe will see another method of accomplishing the same end later.
  955. X
  956. X.OP
  957. X\fBIndenting:\fP  
  958. X.PP
  959. XMost text in letters requires indented
  960. Xprinting.  The usual left-hand margin in wroff is set to
  961. X1 inch from the left printable margin on a page.  
  962. XHowever, this
  963. Xcan be changed in three ways.
  964. X.PP
  965. XThe left hand margin can be changed to any other value by
  966. Xusing ".in".  For instance, ".in 20" changes the left margin
  967. Xto 2 inches from the left printable margin.  
  968. XThe "20" means that the margin is to be set to 20 deci-inches
  969. X(tenths of an inch) from the left printable margin.
  970. XIncidentally, the left printable margin, depending on your printer, may not
  971. Xbe at the left edge of the paper.  
  972. X.PP
  973. XYou can also do it slightly differently.
  974. XUsing ".in +12" would change the left margin to be 1.2 inches
  975. Xto the right of where it was.  In a like fashion, using ".in
  976. X-5" would move the left margin one-half inch to the left.  For
  977. Xexample:
  978. X
  979. X.nf
  980. X.cc #
  981. X.in 10
  982. XThis would be printed at 1.0 inches from the left of the paper.
  983. X
  984. X.in +5
  985. XThis is placed at inch 1.5.
  986. X
  987. X.in 15
  988. XThis is also placed at inch 1.5.
  989. X
  990. X.in -10
  991. XThis would be printed at inch 0.5 (15 -10).
  992. X
  993. X#cc .
  994. X.fi
  995. X.PP
  996. XA variation on setting a margin permanently is just to
  997. Xchange the margin for \fUonly the next line\fU.  Use ".ti +5"
  998. X(for \fBt\fPemporary \fBi\fPndent 5 deci-inches) to indent only the next
  999. Xline (by 0.5 inches).  This is particularly useful at the beginning of
  1000. Xparagraphs.
  1001. X.PP
  1002. XAs an example,
  1003. X
  1004. X.cc #
  1005. X#nf
  1006. X.ti +5
  1007. XThe paragraph printed by processing this text will have an
  1008. Xindented first line.  The remaining lines will not be
  1009. Xindented, but will appear at the left margin.
  1010. X
  1011. Xprocesses into:
  1012. X
  1013. X#fi
  1014. X#ti +5
  1015. XThe paragraph printed by processing this text will have an
  1016. Xindented first line.  The remaining lines will not be
  1017. Xindented, but will appear at the left margin.
  1018. X
  1019. X#cc .
  1020. X.PP
  1021. XAn interesting variation is an "outdent", or hanging leader.
  1022. XHere is an example:
  1023. X
  1024. X.cc #
  1025. X#nf
  1026. X.ti -5
  1027. XThis paragraph has an outdent, or hanging leader in its
  1028. Xfirst line.  This really helps when preparing a report or
  1029. Xother written work with section headings.
  1030. X#fi
  1031. X
  1032. XThe output will appear as:
  1033. X
  1034. X#ti -5
  1035. XThis paragraph has an outdent, or hanging leader in its
  1036. Xfirst line.  This really helps when preparing a report or
  1037. Xother written work with section headings.
  1038. X
  1039. X#cc .
  1040. X.OP
  1041. X\fBBoldfacing\fP, centering, and \fUunderlining\fU:
  1042. X.PP
  1043. XCentering text is easy.  Just use ".ce" as in the
  1044. Xexample at the first of the paper.  One "trick" is to tell
  1045. Xwroff to center a huge number of lines, and then use ".ce 0"
  1046. Xto turn centering off like this:
  1047. X.nf
  1048. X
  1049. X.cc #
  1050. X.ce 100
  1051. XThese and
  1052. Xno telling how
  1053. Xmany other
  1054. Xlines
  1055. X----
  1056. X---
  1057. Xshould be centered.
  1058. X.ce 0
  1059. X#cc .
  1060. X.fi
  1061. X
  1062. X.PP
  1063. XThis results in all of the lines between ".ce 100" and ".ce
  1064. X0" being centered, with no requirement for having to count
  1065. Xlines ahead of time.  
  1066. X.PP
  1067. XThe same stunt works on boldface or underlining:
  1068. X.cc #
  1069. X#nf
  1070. X
  1071. X.ul 100
  1072. X.bd 100
  1073. XAll of the words
  1074. Xin this block will be both boldfaced and
  1075. Xunderlined
  1076. X--
  1077. X-- all the way
  1078. Xdown to here, whereever 
  1079. Xthis is.
  1080. X.bd 0
  1081. X.ul 0
  1082. X
  1083. X#cc .
  1084. X.fi
  1085. X
  1086. X.PP
  1087. XBoldfacing and underlining can be accomplished in two ways.
  1088. XOne way is to use either ".bd" or ".ul" as above.
  1089. X.PP
  1090. XA second way, which is useful when you want to just
  1091. Xunderline or boldface a couple of words is to use an
  1092. X"in-line font change".
  1093. X.PP
  1094. XAn illustration probably is sufficient. 
  1095. X.PP
  1096. XIn this paragraph, we \\fBboldfaced three words\\fP, and \\fUunderlined
  1097. Xtwo\\fU words, and \\fIitalicized three words\\fP, and printed a \\\\.  
  1098. XHere is how wroff printed it.
  1099. X.PP
  1100. XIn this paragraph, we \fBboldfaced three words\fP, and \fUunderlined
  1101. Xtwo\fU words, and \fIitalicized three words\fP, and printed a \\.  
  1102. XHere is how wroff printed it.
  1103. X.PP
  1104. XIn-line font changes are discussed in more detail in a later section.
  1105. X.OP
  1106. X\fBUse of Macros:\fP
  1107. X.PP
  1108. X"Macros" are collections of frequently used commands that
  1109. Xcan be called by a single name.  You get to invent the name.
  1110. X.PP
  1111. XIn typing this document, we frequently had need to 
  1112. X"skip 3 lines and then temporarily outdent by 5 spaces" when
  1113. Xwe came to a new section.  Rather than always type
  1114. X.cc #
  1115. X
  1116. X#nf
  1117. X.sp 3
  1118. X.ti -5
  1119. X
  1120. X#fi
  1121. Xat the start of every section, we instead defined a "macro"
  1122. Xnamed ".OP" like this:
  1123. X
  1124. X#nf
  1125. X
  1126. X.de OP
  1127. X.sp 3
  1128. X.ti -5
  1129. X.en
  1130. X
  1131. X#nf
  1132. XAt the start of every new section, we just typed:
  1133. X
  1134. X.OP
  1135. XThe start of the section ...
  1136. X.PP
  1137. X
  1138. Xand went on about our business.
  1139. X#cc .
  1140. X.fi
  1141. X.PP
  1142. XMacros are really powerful.  A well thought out collection
  1143. Xof macros can make writing a letter or preparing a memo a
  1144. Xbreeze.  Macros can be defined and placed in a file for
  1145. Xfuture use.  The file can be included in any document by
  1146. Xusing the ".so" command to read the macro file before you
  1147. Xstart processing.
  1148. X.PP
  1149. XDon't overlook the power of macros.  Here is a set we use a
  1150. Xlot.  They were placed in a file called "macros" by using
  1151. X"vi".  
  1152. X
  1153. X.in +5
  1154. X.OP
  1155. Xfile macros contains:
  1156. X.nf
  1157. X.cc #
  1158. X
  1159. X.de DATE
  1160. X.in +30
  1161. X$1 $2 $3
  1162. X.br
  1163. X.en
  1164. X.de TO
  1165. X.in 10
  1166. X.sp 3
  1167. X.nf
  1168. X.en
  1169. X.de TEXT
  1170. X.sp 3
  1171. X.fi
  1172. X.ti +5
  1173. X.en
  1174. X.de SIGN
  1175. X.sp 3
  1176. X.in +30
  1177. X.nf
  1178. X.en
  1179. X#cc .
  1180. X.in -5
  1181. X
  1182. X.fi
  1183. X.OP
  1184. XNow when we want to write a letter, we write
  1185. X.nf
  1186. X.in +5
  1187. X.cc #
  1188. X
  1189. X.DATE October 4, 1988
  1190. X.TO
  1191. XMr. Joe Smith
  1192. XSomePlace
  1193. XSomewhere, USA
  1194. X
  1195. XDear Joe:
  1196. X.TEXT
  1197. XHere is the letter and so forth ...
  1198. X.SIGN
  1199. XYours Truly,
  1200. X
  1201. XFred
  1202. X#cc .
  1203. X.fi
  1204. X.in -5
  1205. X
  1206. XWe print the letter by writing "wroff macros filename".
  1207. X.bp
  1208. X.OP
  1209. X\fBScanning for errors:\fP  
  1210. X.PP
  1211. Xwroff is somewhat sensitive to
  1212. Xerrors in input.  It is sometimes useful to scan a document \fIbefore\fP
  1213. Xyou print it to see if all of the wroff commands have been entered 
  1214. Xcorrectly.  Use the command line option "-s" to scan for errors
  1215. Xif you are concerned.
  1216. X.PP
  1217. XIf you enter "wroff -s filename", then wroff will not print anything
  1218. Xat all, either on the screen, or on the printer.  If there is some kind
  1219. Xof problem with any of the wroff commands in your paper, wroff will report
  1220. Xthat problem, and the approximate location of it, so that you can fix it
  1221. Xbefore you go to the trouble and expense of printing the document.
  1222. X.OP
  1223. X\fBFonts:\fP
  1224. X.PP
  1225. XOne of the biggest pleasures in using wroff is that you can combine various
  1226. Xtypefaces in a document to give a pleasing appearance.  
  1227. X.PP
  1228. XThere are several fonts available.  Here is a current list:
  1229. X.nf
  1230. X\fT
  1231. Xsymbol                   font 
  1232. X
  1233. X.in +5
  1234. XB        Times Roman 12 point boldface 
  1235. XI        Times Roman 12 point italics
  1236. XM        mountable - default is Presentation 18 bold
  1237. XT        Courier 12 point
  1238. XP        return to previous font
  1239. XU        toggle underlining
  1240. X0            Times Roman 12 point Normal (default)    
  1241. X1        Presentation 18 point - synonymous with M
  1242. X2        Helvetica Normal 6 point
  1243. X\fP
  1244. X.fi
  1245. X.in -5
  1246. X.PP
  1247. XIn order to make effective use of fonts, you must
  1248. Xunderstand what is meant by "proportional spacing."
  1249. X.PP
  1250. XYou may have noticed that in this document, not all letters in 
  1251. Xa word are the same "width".  For instance, the letter "i" is much more
  1252. Xnarrow than the letter "M".  These letters were printed with a proportionally
  1253. Xspaced font.  
  1254. X.PP
  1255. XProportional spacing is pleasant to read.  It gives a "typeset" quality
  1256. Xto printed work.  Most (but not all) of 
  1257. Xthis document was printed using Times Roman 12 point
  1258. XNormal type.
  1259. X.PP
  1260. XWroff, in the default mode, allows for proportional printing, and adjusts
  1261. Xthe spacing in lines accordingly.
  1262. X.PP
  1263. XIn the table above, the only proportional fonts are the "Times Roman" fonts.
  1264. XThe other fonts are "fixed spacing fonts", which means that each letter
  1265. Xtakes the same amount of space as any other letter.  Fixed spacing fonts
  1266. Xare especially useful for preparing portions of a document that have
  1267. Xlines which need to "line-up" with previous lines.  One such example is
  1268. Xwhen preparing a table.
  1269. X.PP
  1270. XYou can switch fonts, even in the middle of a line, by using
  1271. Xan "embedded font change."  To do this, use a "\\f" followed by the symbol
  1272. Xfrom the table above that indicates which font you want.
  1273. X.PP
  1274. XAs an example, the line:
  1275. X.nf
  1276. X.in +5
  1277. X
  1278. X\\fBboldface this\\fP and \\fIitalicize this\\fP
  1279. X.in -5
  1280. X.fi
  1281. X
  1282. Xwould print as:
  1283. X.nf
  1284. X
  1285. X\fBboldface this\fP and \fIitalicize this\fP
  1286. X
  1287. X.fi
  1288. X.OP
  1289. X\fBBuilding tables and using '.nf':\fP
  1290. X.PP
  1291. XThe only fixed spacing fonts available above are the Courier 12 point,
  1292. Xand the Presentation 18 point.  (Point size indicates the height of letters,
  1293. Xnot their width.)
  1294. X.PP
  1295. XIncidentally, you may occasionally want to print the character "\\".
  1296. XIf you want to enter such a character,  you may enter '\\\\' in the document.
  1297. XThis works for other characters, too.  Entering '\\x' will print the
  1298. Xcharacter 'x'.  This seems useless until you realize that it is an alternative
  1299. Xway of protecting a line that begins with a period.  
  1300. X.PP
  1301. XHere is an example table:
  1302. X.nf
  1303. X.in +5
  1304. X
  1305. X\fT
  1306. X
  1307. X\.nf
  1308. X\.in +5
  1309. X\\fT
  1310. XName            Address
  1311. XJoe Smith        Somewhere
  1312. XJames Jones        Nowhere
  1313. XSally Sue        Anywhere
  1314. X\\.50 caliber           Guns
  1315. X\\fP
  1316. X\.in -5
  1317. X
  1318. X.in -5
  1319. X\fP
  1320. X.PP
  1321. XThis was printed by wroff as:
  1322. X
  1323. X
  1324. X.nf
  1325. X.in +5
  1326. X\fT
  1327. XName            Address
  1328. XJoe Smith        Somewhere
  1329. XJames Jones        Nowhere
  1330. XSally Sue        Anywhere
  1331. X\.50 caliber         Guns
  1332. X\fP
  1333. X.fi
  1334. X.in -5
  1335. X
  1336. X.PP
  1337. XJust switching from a proportional font to a fixed font in the same
  1338. Xline, when in fill mode gives no problems at all.  Wroff may become 
  1339. Xconfused when you build tables in non-fill mode and mix several fonts
  1340. Xtogether.  A good word of advice, then, is to build tables in non-fill
  1341. Xmode, using a fixed font, just as we did above.
  1342. X.PP
  1343. XIf for some reason
  1344. Xyou absolutely \fIinsist\fP on using a proportional font to build a table,
  1345. Xyou can use an "anchor".  The "anchor" characters cause a specific
  1346. Xplace in the text to appear in a certain column.  The anchor consists of the
  1347. Xstring "\\f|".
  1348. XHere is an example:
  1349. X.nf
  1350. X.sp
  1351. X.in +5
  1352. X\fT
  1353. Xage    \\f|14
  1354. Xdate    \\f|12
  1355. Xtoday    \\f|2
  1356. X\fP
  1357. X.in -5
  1358. X.fi
  1359. X.PP
  1360. XThis produces the following output:
  1361. X.sp
  1362. X.in +5
  1363. X.nf
  1364. Xage    \f|14
  1365. Xdate    \f|12
  1366. Xtoday    \f|2
  1367. X.in -5
  1368. X.fi
  1369. X.PP
  1370. XWhen processing a line in non-fill mode under a proportional font,
  1371. Xwroff will attempt to duplicate the appearance of the original line as
  1372. Xbest it can.   Wroff takes the original line and determines by counting
  1373. Xcharacters just where on a page that it should begin printing a word.  
  1374. XIt assumes that each character is 0.1 inches in width.
  1375. X.PP
  1376. XWroff then attempts to begin each word in the line at whatever place on
  1377. Xthe page is indicated by the character position of the first letter in
  1378. Xthe word.  This would make for some "funny" looking lines, unless you
  1379. Xplaced the anchors in the line.
  1380. X.OP
  1381. X\fBConclusions:\fP  
  1382. X.PP
  1383. XThere is a lot to wroff, and a lot more to
  1384. Xlearn.  Most of the commands are reasonable to use, and
  1385. Xactually most people only need a few of the commands.
  1386. XStudying the User's Guide will repay a careful reader.
  1387. X.PP
  1388. XAppendix A attached to this paper is a technical description
  1389. Xof all of wroff's commands.  After you gain skill with
  1390. Xwroff, this appendix will probably become very useful to
  1391. Xyou.
  1392. X.PP
  1393. XAppendix B is a listing of the raw unprocessed file that
  1394. Xwas used to create this tutorial.  It should provide a treasure
  1395. Xtrove of examples.
  1396. X.PP
  1397. XEnjoy !
  1398. END_OF_FILE
  1399.   if test 16027 -ne `wc -c <'doc/wroff.tut.w'`; then
  1400.     echo shar: \"'doc/wroff.tut.w'\" unpacked with wrong size!
  1401.   fi
  1402.   # end of 'doc/wroff.tut.w'
  1403. fi
  1404. if test ! -d 'source' ; then
  1405.     echo shar: Creating directory \"'source'\"
  1406.     mkdir 'source'
  1407. fi
  1408. if test -f 'source/format.c' -a "${1}" != "-c" ; then 
  1409.   echo shar: Will not clobber existing file \"'source/format.c'\"
  1410. else
  1411.   echo shar: Extracting \"'source/format.c'\" \(12233 characters\)
  1412.   sed "s/^X//" >'source/format.c' <<'END_OF_FILE'
  1413. X/* this file contains the line formatting stuff */
  1414. X
  1415. X#include <stdio.h>
  1416. X#include <ctype.h>
  1417. X#include "defs.h"
  1418. X#include "externs.c"
  1419. X
  1420. Xformat(s,ifile,f)
  1421. Xchar s[];
  1422. XFILE *ifile,*f;
  1423. X{
  1424. X    /* The idea is to collect output into a buffer (outbuf)
  1425. X       and when the buffer is complete, write it. 
  1426. X       The variable s contains the text of the last line
  1427. X       read from the input file.  The output buffer is
  1428. X       in variable "outbuf".  */
  1429. X    
  1430. X    int i;
  1431. X
  1432. X    char word[MAXSTR],tstring[MAXSTR];
  1433. X    int wordlength;
  1434. X    int diff;
  1435. X    int chcnt;
  1436. X
  1437. X    /* first "doctor" the line if boldcount or italicscount > 0 */
  1438. X    if (BOLDCNT > 0) {
  1439. X        addstr(s,"\\fB","\\fP");
  1440. X        BOLDCNT--;
  1441. X    }
  1442. X    if (ITALCNT > 0) {
  1443. X        addstr(s,"\\fI","\\fP");
  1444. X        ITALCNT--;
  1445. X    }
  1446. X    if (ULCOUNT > 0) {
  1447. X        addstr(s,"\\fU","\\fU");
  1448. X        ULCOUNT--;
  1449. X    }
  1450. X
  1451. X    /* now if the line should be centered, do it, otherwise just
  1452. X      format it */
  1453. X    if (!FILLMODE || CNTRCNT > 0) {
  1454. X        /* just parse the line to get the length */
  1455. X        i = 0;
  1456. X        while (s[i] != '\0') {
  1457. X            getword(word,s,&i);
  1458. X            parseword(tstring,word,&wordlength,&chcnt,ifile,f);
  1459. X            append(tstring,chcnt);
  1460. X            CURRX = CURRX + wordlength;
  1461. X        }
  1462. X        endln();
  1463. X
  1464. X        TEMPINDENT = 0;
  1465. X        if (CNTRCNT > 0) {
  1466. X            TEMPINDENT = (RMARGIN - LMARGIN - CURRX)/2;
  1467. X            CNTRCNT--;
  1468. X        }
  1469. X
  1470. X        output (ifile,f,0);
  1471. X    }
  1472. X    else { /* don't center it */
  1473. X
  1474. X    /* get a word from s */
  1475. X    i = 0;
  1476. X    while ( s[i] != '\0') {
  1477. X        getword(word,s,&i);
  1478. X        /* now add the word to the buffer */
  1479. X        /* we have to parse the word to find any
  1480. X           embedded font changes, and to determine its printable
  1481. X           length */
  1482. X        parseword(tstring,word,&wordlength,&chcnt,ifile,f);
  1483. X
  1484. X        diff = RMARGIN - LMARGIN - TEMPINDENT;
  1485. X        if (( length(' ') + CURRX + wordlength) >= diff) { 
  1486. X            endln();
  1487. X            output(ifile,f,diff);
  1488. X        }
  1489. X        append(tstring,chcnt);
  1490. X        CURRX = CURRX + wordlength ;
  1491. X        /* note CURRX is current printable position on line */
  1492. X
  1493. X    }
  1494. X    } /* of don't center it */
  1495. X}
  1496. X
  1497. X
  1498. X/* getword looks inside string s, starts at position i, and returns
  1499. X   the next word in t */
  1500. XVOID getword(t,s,i)
  1501. Xchar t[];
  1502. Xchar s[];
  1503. Xint *i;
  1504. X{
  1505. X    int j;
  1506. X    /* first skip any white space */
  1507. X    while ( s[*i] != '\0' && isspace(s[*i]) ) (*i)++;
  1508. X    
  1509. X    /* now copy into string t */
  1510. X    j = 0;
  1511. X    while ( s[*i] != '\0' && !isspace(s[*i]) ) {
  1512. X        t[j] = s[*i];
  1513. X        (*i)++;
  1514. X        j++;
  1515. X    }
  1516. X    t[j] = '\0';
  1517. X    /* note that s[*i] is either '\0' or it is white space */
  1518. X
  1519. X}
  1520. X
  1521. X
  1522. X/* append adds the string to the existing output buffer.  Note that
  1523. X   the buffer does NOT have a NULL at its end.  */
  1524. XVOID append(s,chcnt)
  1525. Xchar s[];
  1526. Xint chcnt;
  1527. X{
  1528. X    int j;
  1529. X    if (shadd &&  obufpos != 0 && s[0] != '\0') {
  1530. X        outbuf[obufpos] = ' ';
  1531. X        obufpos++;
  1532. X        outbuf[obufpos] = SHIFTOUT;
  1533. X        obufpos++;
  1534. X        CHARCNT = CHARCNT + 1;
  1535. X        CURRX = CURRX + length(' ');
  1536. X    }
  1537. X    else
  1538. X        shadd = TRUE;
  1539. X
  1540. X    j = 0;
  1541. X    while (s[j] != '\0') {
  1542. X        outbuf[obufpos] = s[j];
  1543. X        j++;
  1544. X        obufpos++;
  1545. X    }
  1546. X    if (LASTPERIOD) {
  1547. X        outbuf[obufpos] = ' ';
  1548. X        obufpos++;
  1549. X        outbuf[obufpos] = SHIFTOUT;
  1550. X        obufpos++;
  1551. X        CHARCNT = CHARCNT + 1;
  1552. X        CURRX = CURRX + length(' ');
  1553. X        LASTPERIOD = FALSE;
  1554. X    }
  1555. X    /* WARNING --- outbuf does NOT have a NULL at its end */
  1556. X    CHARCNT = CHARCNT + chcnt ;
  1557. X
  1558. X
  1559. X}
  1560. X
  1561. X
  1562. X/* we have to parse the word to find any
  1563. X   embedded font changes, and to determine its printable
  1564. X   length.  The word is copied into tstring with any control characters
  1565. X   expanded and embedded.  This needs to be a FSM. */
  1566. X
  1567. XVOID parseword(tstring,word,wordlength,chcnt,ifile,f)
  1568. Xchar tstring[],word[];
  1569. Xint *wordlength;
  1570. Xint *chcnt;
  1571. XFILE *ifile, *f;
  1572. X{
  1573. X    int nextstate;
  1574. X    int i; /* for counter of subscript in word */
  1575. X    int j;  /* subscript in tstring */
  1576. X    int k; /* subscript for copying */
  1577. X    int m;  /* general counter */
  1578. X
  1579. X    char tstr[MAXSTR], tempstr[MAXSTR];    /* a temporary string */
  1580. X    char ch,regname;
  1581. X
  1582. X    *chcnt = 0;
  1583. X    *wordlength = 0;
  1584. X    i = 0;
  1585. X    j = 0;
  1586. X
  1587. X    nextstate = 0;
  1588. X    if (InExpression)
  1589. X        nextstate = 4;
  1590. X    
  1591. X    if (InMacro)
  1592. X        nextstate = 17;
  1593. X
  1594. X    while (nextstate != 999) {
  1595. X        ch = word[i];
  1596. X        switch(nextstate) {
  1597. X            case 0: /* start state */
  1598. X                if (ch == '\\')
  1599. X                    nextstate = 1;
  1600. X                else if (ch == '\0' || ch == EOF)
  1601. X                    nextstate = 999;
  1602. X                else  /* copy state */
  1603. X                    nextstate = 1000;
  1604. X                break;
  1605. X            
  1606. X            case 1 : /* it's a '\' */
  1607. X                i++;
  1608. X                ch = word[i];
  1609. X                if (ch == '\\')
  1610. X                    nextstate = 2;
  1611. X                else if (ch == '(')
  1612. X                    nextstate = 3;
  1613. X                else if (ch == '{')
  1614. X                    nextstate = 17;
  1615. X                else if (ch == '[')
  1616. X                    nextstate = 4;
  1617. X                else if (ch == 'f')
  1618. X                    nextstate = 8;
  1619. X                else 
  1620. X                    /* not a state -- must be an escaped
  1621. X                    character, so just copy it */
  1622. X                    nextstate = 1000;
  1623. X                break;
  1624. X            
  1625. X            case 2:  /* it is an escaped '\' */
  1626. X                tstring[j] = ch;
  1627. X                j++;
  1628. X                tstring[j] = SHIFTOUT;
  1629. X                j++;
  1630. X                *wordlength = *wordlength + length('\\');
  1631. X                *chcnt = *chcnt + 1;
  1632. X                i++;
  1633. X                nextstate = 0; /* start it over */
  1634. X                break;
  1635. X
  1636. X            case 3:  /* it is an in-line register */
  1637. X                /* first get the name of the register -- it should
  1638. X                be a single character */
  1639. X                i++;
  1640. X                regname = word[i];
  1641. X                i++; /* advance to after the register name */
  1642. X                if (word[i] == 'C') {
  1643. X                    /* interpolate as a character */
  1644. X                    sprintf(tempstr,"%c",REG(regname));
  1645. X                    i++;
  1646. X                }
  1647. X                else  /* interpolate as a number */
  1648. X                    sprintf(tempstr,"%d",REG(regname));
  1649. X                if (word[i]!= ')') {
  1650. X                    fprintf(stderr,"error in register name -- one letter only!\n");
  1651. X                    exit(1);
  1652. X                }
  1653. X                i++; /* to skip the ')' */
  1654. X                /* now append tempstr to the output string */
  1655. X                k = 0;
  1656. X                while (tempstr[k] != '\0') {
  1657. X                  tstring[j] = tempstr[k];
  1658. X                  j++;
  1659. X                  tstring[j] = SHIFTOUT;
  1660. X                  *wordlength = *wordlength + length(tempstr[k]);
  1661. X                  *chcnt = *chcnt + 1;
  1662. X                  j++;
  1663. X                  k++;
  1664. X                }
  1665. X                nextstate = 0;
  1666. X
  1667. X                break;
  1668. X
  1669. X            case 4: /* it is an expression */
  1670. X                /* don't forget to advance i to end of expression */
  1671. X                /* the end of the expression is signified by ']' */
  1672. X                InExpression = TRUE;
  1673. X                tstr[0] = '\0';
  1674. X                if (word[i] == '[') i++; /* skip the '[' */
  1675. X                k = 0;
  1676. X                while (word[i] != '\0' && word[i] != ']') {
  1677. X                    tstr[k] = word[i];
  1678. X                    i++;
  1679. X                    k++;
  1680. X                }
  1681. X                tstr[k] = ' ';
  1682. X                tstr[k + 1] = '\0';
  1683. X                strcat(expstr,tstr);
  1684. X                if (word[i] == ']') {
  1685. X                    InExpression = FALSE;
  1686. X                    eval(expstr);
  1687. X                    expstr[0] = '\0';
  1688. X                }
  1689. X
  1690. X                if (word[i] == ']') i++; /* skip the whatever */
  1691. X                nextstate = 0;
  1692. X
  1693. X                break;
  1694. X
  1695. X            case 8:  /* it is a font change, I guess.  find out which one */
  1696. X                i++;
  1697. X                ch = word[i];
  1698. X                switch (ch) {
  1699. X                  case '0' : /* return to default font */
  1700. X                    pushf(cfont,&fstk);
  1701. X                    pushi(clen,&ipstk);
  1702. X                    clen = defl;
  1703. X                    strcpy(cfont,prinit);
  1704. X                    k = 0;
  1705. X                    if (!FONTCHANGE)
  1706. X                        cfont[0] = '\0';
  1707. X                    while (cfont[k] != '\0') {
  1708. X                        tstring[j] = cfont[k];
  1709. X                        k++;
  1710. X                        j++;
  1711. X                    }
  1712. X                    break;
  1713. X                  case 'M': /* mountable font */
  1714. X                  case '1' : /* Presentation 18 point */
  1715. X                    pushf(cfont,&fstk);
  1716. X                    pushi(clen,&ipstk);
  1717. X                    strcpy(cfont,Pres);
  1718. X                    clen = &P18bl[0];
  1719. X                    k = 0;
  1720. X                    if (!FONTCHANGE ) cfont[0] = '\0';
  1721. X                    while (cfont[k] != '\0') {
  1722. X                        tstring[j] = cfont[k];
  1723. X                        k++;
  1724. X                        j++;
  1725. X                    }
  1726. X                    break;
  1727. X                  case '2' : /* Helv. 6 point font */
  1728. X                    pushf(cfont,&fstk);
  1729. X                    pushi(clen,&ipstk);
  1730. X
  1731. X                    sprintf(cfont,"%c&10O%c(0U%c(s1p6vsb4T",ESC,ESC,ESC);
  1732. X                    clen = &H6nl[0];
  1733. X                    k = 0;
  1734. X                    if (!FONTCHANGE ) cfont[0] = '\0';
  1735. X                    while (cfont[k] != '\0') {
  1736. X                        tstring[j] = cfont[k];
  1737. X                        k++;
  1738. X                        j++;
  1739. X                    }
  1740. X                    break;
  1741. X                  case 'B' : /* Times Roman bold face */
  1742. X                    pushf(cfont,&fstk);
  1743. X                    pushi(clen,&ipstk);
  1744. X                    clen = &H12bl[0];
  1745. X                    sprintf(cfont,"%c&l0O%c(0U%c(s1p12vs3b5T",ESC,ESC,ESC);
  1746. X                    if (!FONTCHANGE ) cfont[0] = '\0';
  1747. X                    k = 0;
  1748. X                    while (cfont[k] != '\0') {
  1749. X                        tstring[j] = cfont[k];
  1750. X                        k++;
  1751. X                        j++;
  1752. X                    }
  1753. X                    break;
  1754. X                  case 'I' : /* Times Roman 12 point italics */
  1755. X                    pushf(cfont,&fstk);
  1756. X                    pushi(clen,&ipstk);
  1757. X                    sprintf(cfont,"%c&l0O%c(0U%c(s1p12v1sb5T",ESC,ESC,ESC);
  1758. X                    clen = &H12il[0];
  1759. X                    if (!FONTCHANGE ) cfont[0] = '\0';
  1760. X                    k = 0;
  1761. X                    while (cfont[k] != '\0') {
  1762. X                        tstring[j] = cfont[k];
  1763. X                        k++;
  1764. X                        j++;
  1765. X                    }
  1766. X                    break;
  1767. X                  case 'T' : /* Courier */
  1768. X                    pushf(cfont,&fstk);
  1769. X                    pushi(clen,&ipstk);
  1770. X                    sprintf(cfont,"%c&10O%c(0U%c(sp10h12vsb3T",ESC,ESC,ESC);
  1771. X                    clen = &C12nl[0];
  1772. X                    if (!FONTCHANGE ) cfont[0] = '\0';
  1773. X                    k = 0;
  1774. X                    while (cfont[k] != '\0') {
  1775. X                        tstring[j] = cfont[k];
  1776. X                        k++;
  1777. X                        j++;
  1778. X                    }
  1779. X                    break;
  1780. X                  case 'U' : /* underline toggle */
  1781. X                    if (ULSTATE == FALSE) {
  1782. X                        sprintf(tempstr,"%c&dD",ESC);
  1783. X                        ULSTATE = TRUE;
  1784. X                    }
  1785. X                    else {
  1786. X                        sprintf(tempstr,"%c&d@",ESC);
  1787. X                        ULSTATE = FALSE;
  1788. X                    }
  1789. X                    if (!FONTCHANGE ) tempstr[0] = '\0';
  1790. X                    k = 0;
  1791. X                    while (tempstr[k] != '\0') {
  1792. X                        tstring[j] = tempstr[k];
  1793. X                        k++;
  1794. X                        j++;
  1795. X                    }
  1796. X                    break;
  1797. X                  case 'P' : /* pop font stack */
  1798. X                    popf(cfont,&fstk);
  1799. X                    popi(&clen,&ipstk);
  1800. X                    k = 0;
  1801. X                    if (!FONTCHANGE ) cfont[0] = '\0';
  1802. X                    while (cfont[k] != '\0') {
  1803. X                        tstring[j] = cfont[k];
  1804. X                        k++;
  1805. X                        j++;
  1806. X                    }
  1807. X                    break;
  1808. X
  1809. X                  case '|' : /* it's an anchor */
  1810. X                    m = 0;
  1811. X                    while (m <= j) {
  1812. X                        if (tstring[m] == SHIFTOUT) {
  1813. X                            tstring[m] = ANCHOR;
  1814. X                            *chcnt = *chcnt - 1;
  1815. X                        }
  1816. X                        m++;
  1817. X                    }
  1818. X                    sprintf(tempstr,"%c*p%dX",ESC,TEMPINDENT + LMARGIN + i*length('w') );
  1819. X                    k = 0;
  1820. X                    if (!FONTCHANGE ) tempstr[0] = '\0';
  1821. X                    while (tempstr[k] != '\0') {
  1822. X                        tstring[j] = tempstr[k];
  1823. X                        k++;
  1824. X                        j++;
  1825. X                    }
  1826. X                    break;
  1827. X
  1828. X                } /* of switch */
  1829. X                i++;
  1830. X                nextstate = 0; /* start over */
  1831. X                break;
  1832. X
  1833. X            case 17: /* expand in-line string macro */
  1834. X                /* don't forget to advance i */
  1835. X                InMacro = TRUE;
  1836. X                if (word[i] == '{') i++; /* skip the '{' */
  1837. X                k = 0;
  1838. X                while (word[i] != '\0' && word[i] != '}') {
  1839. X                    tstr[k] = word[i];
  1840. X                    i++;
  1841. X                    k++;
  1842. X                }
  1843. X                tstr[k] = ' ';
  1844. X                tstr[k + 1] = '\0';
  1845. X                strcat(macline,tstr);
  1846. X                if (word[i] == '}') {
  1847. X                    /* skip the '}' */
  1848. X                    i++;
  1849. X                    /* end the macline and process the
  1850. X                       macro */
  1851. X                    InMacro = FALSE;
  1852. X                    procmacro (macline,ifile,f);
  1853. X                    macline[0] = '\0';
  1854. X                    tstr[0] = '\0';
  1855. X                    
  1856. X                }
  1857. X
  1858. X                nextstate = 0;
  1859. X
  1860. X                break;
  1861. X
  1862. X
  1863. X            case 999 : /* at the end state */
  1864. X                break;
  1865. X
  1866. X            case 1000 : /* copy state */
  1867. X            default:
  1868. X                tstring[j] = ch;
  1869. X                j++;
  1870. X                tstring[j] = SHIFTOUT;
  1871. X                nextstate = 0; /* start it over */
  1872. X                *wordlength = *wordlength + length(ch);
  1873. X                *chcnt = *chcnt + 1;
  1874. X                j++;
  1875. X                i++;
  1876. X                break;
  1877. X            
  1878. X        }  /* of switch */
  1879. X    }  /* of while nextstate */
  1880. X    tstring[j] = '\0';
  1881. X    k = j - 1;
  1882. X    while (k > 0 && (isspace(tstring[k]) || tstring[k] == SHIFTOUT) ) k--;
  1883. X    if (k > 0 && ispunct(tstring[k]) )
  1884. X        LASTPERIOD = TRUE;
  1885. X    else
  1886. X        LASTPERIOD = FALSE;
  1887. X
  1888. X}  /* of parseword */
  1889. X
  1890. X
  1891. X
  1892. X/* length returns the length of a character, measured in dots */
  1893. Xint length(c)
  1894. Xchar c;
  1895. X{
  1896. X    /* temporarily */
  1897. X    return *(clen + (c & 0xff));
  1898. X}
  1899. X
  1900. X/* clean out the buffers, print anything collected, and reset counters */
  1901. XVOID brek(ifile,ofile)
  1902. XFILE *ifile,*ofile;
  1903. X{
  1904. X    /* be sure to empty the buffer again */
  1905. X    outbuf[obufpos] = '\0';
  1906. X    if (outbuf[0] != '\0') 
  1907. X        output(ifile,ofile,0);
  1908. X    outbuf[0] = '\0';
  1909. X    obufpos = 0;
  1910. X    CURRX = 0;
  1911. X    CHARCNT = 0;
  1912. X}
  1913. X
  1914. X
  1915. X/* process a line, but do not justify it, and preserve the spaces */
  1916. Xnonfill(s,ifile,f)
  1917. Xchar s[];
  1918. XFILE *ifile,*f;
  1919. X{
  1920. X    /* The idea is to collect output into a buffer (outbuf)
  1921. X       and when the buffer is complete, write it. 
  1922. X       The variable s contains the text of the last line
  1923. X       read from the input file.  The output buffer is
  1924. X       in variable "outbuf".  */
  1925. X    
  1926. X    int i;
  1927. X
  1928. X    char word[MAXSTR],tstring[MAXSTR];
  1929. X    int wordlength;
  1930. X    int chcnt;
  1931. X
  1932. X    /* first "doctor" the line if boldcount or italicscount > 0 */
  1933. X    if (BOLDCNT > 0) {
  1934. X        addstr(s,"\\fB","\\fP");
  1935. X        BOLDCNT--;
  1936. X    }
  1937. X    if (ITALCNT > 0) {
  1938. X        addstr(s,"\\fI","\\fP");
  1939. X        ITALCNT--;
  1940. X    }
  1941. X    if (ULCOUNT > 0) {
  1942. X        addstr(s,"\\fU","\\fU");
  1943. X        ULCOUNT--;
  1944. X    }
  1945. X
  1946. X    /* now if the line should be centered, do it, otherwise just
  1947. X      format it */
  1948. X    if ( CNTRCNT > 0) {
  1949. X        /* just parse the line to get the length */
  1950. X        i = 0;
  1951. X        while (s[i] != '\0') {
  1952. X            getword(word,s,&i);
  1953. X            parseword(tstring,word,&wordlength,&chcnt,ifile,f);
  1954. X            append(tstring,chcnt);
  1955. X            CURRX = CURRX + wordlength;
  1956. X        }
  1957. X        endln();
  1958. X
  1959. X        TEMPINDENT = (RMARGIN - LMARGIN - CURRX)/2;
  1960. X        CNTRCNT--;
  1961. X
  1962. X        output (ifile,f,0);
  1963. X    }
  1964. X    else { /* don't center it */
  1965. X
  1966. X    /* expand s to include any font changes */
  1967. X    parseword(tstring,s,&wordlength,&chcnt,ifile,f);
  1968. X    strcpy(outbuf,tstring);
  1969. X    CURRX = CURRX + wordlength ;
  1970. X    TEMPINDENT = 0;
  1971. X    output(ifile,f,0);
  1972. X
  1973. X    } /* of don't center it */
  1974. X}
  1975. X
  1976. END_OF_FILE
  1977.   if test 12233 -ne `wc -c <'source/format.c'`; then
  1978.     echo shar: \"'source/format.c'\" unpacked with wrong size!
  1979.   fi
  1980.   # end of 'source/format.c'
  1981. fi
  1982. echo shar: End of archive 1 \(of 5\).
  1983. cp /dev/null ark1isdone
  1984. MISSING=""
  1985. for I in 1 2 3 4 5 ; do
  1986.     if test ! -f ark${I}isdone ; then
  1987.     MISSING="${MISSING} ${I}"
  1988.     fi
  1989. done
  1990. if test "${MISSING}" = "" ; then
  1991.     echo You have unpacked all 5 archives.
  1992.     rm -f ark[1-9]isdone
  1993. else
  1994.     echo You still must unpack the following archives:
  1995.     echo "        " ${MISSING}
  1996. fi
  1997. exit 0
  1998. exit 0 # Just in case...
  1999. -- 
  2000. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2001. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2002. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2003. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2004.